package com.tyl.bk;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
/**
 *抛出异常
 **/
// 队列
public class BlockingQueueTest1 {

    public static void main(String[] args) {
        BlockingQueue blockingQueue= new ArrayBlockingQueue<>(3);
        System.out.println(blockingQueue.add("a"));
        System.out.println(blockingQueue.add("b"));
        System.out.println(blockingQueue.add("c"));
        System.out.println(blockingQueue.element());
        //异常Queue full
        // System.out.println(blockingQueue.add("d"));
        System.out.println("=============================");
        System.out.println(blockingQueue.remove());
        System.out.println(blockingQueue.remove());
        System.out.println(blockingQueue.remove());
        //异常NoSuchElementException
        //System.out.println(blockingQueue.remove());
    }

}

